#ifndef GENERIC_QUEUE_H
#define GENERIC_QUEUE_H

#include "network.h"

#include <list>
#include <boost/shared_ptr.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>

#include <iostream>
using namespace std;

using namespace std;

namespace network {
	template <class T>
	class generic_queue {
	public:
		void put(boost::shared_ptr<T> obj)
		{
			boost::mutex::scoped_lock l(_monitor);
			_list.push_back(obj);
			_cond.notify_one();
		}
		boost::shared_ptr<T> get()
		{
			boost::mutex::scoped_lock l(_monitor);
			while(_list.empty()) {
				_cond.wait(l);
			}
			boost::shared_ptr<T> tmp(_list.front());
			_list.pop_front();
			return tmp;
		}
	private:
		boost::mutex _monitor;
		boost::condition _cond;
		list<boost::shared_ptr<T> > _list;
	};
}

#endif
